import http from '@/services/request'

// 注册
export const register = (data) => {
  return http({
    url: 'api/marketing/register',
    method: 'post',
    data,
  })
}

// 获取验证码
export const getCode = (data) => {
  return http({
    url: 'api/marketing/sendEmailCode',
    method: 'post',
    data,
  })
}

//获取可注册用的角色
export const getRoles = () => {
  return http({
    url: 'api/marketing/getActors',
    method: 'get',
  })
}

// 登录
export const login = (data) => {
  return http({
    url: 'api/marketing/login',
    method: 'post',
    data,
  })
}

// 修改密码
export const updatePwd = (data) => {
  return http({
    url: 'api/marketing/updatePassword',
    method: 'post',
    data,
  })
}

// 忘记密码
export const forgetPwd = (data) => {
  return http({
    url: 'api/marketing/forgetPassword',
    method: 'post',
    data,
  })
}

// 获取用户信息
export const getUserInfo = () => {
  return http({
    url: 'api/marketing/user/info',
    method: 'get',
  })
}

// 退出登录
export const loginOut = () => {
  return http({
    url: 'api/marketing/user/logout',
    method: 'post',
  })
}

// 刷新token
export const refreshToken = (refreshToken) => {
  return http({
    url: 'api/marketing/refreshToken',
    method: 'post',
    data: {
      refreshToken,
    },
  })
}

// 获取用户角色,要登陆
export const getUserRoles = () => {
  return http({
    url: 'api/marketing/user/role',
    method: 'get',
  })
}

// 获取用户通知
export const getMessage = (params) => {
  return http({
    url: 'api/marketing/user/notice',
    method: 'get',
    params,
  })
}

// 已读通知
export const readMessage = (data) => {
  return http({
    url: 'api/marketing/user/readNotice',
    method: 'post',
    data,
  })
}

// 修改联系方式
export const updateContract = (data) => {
  return http({
    url: 'api/marketing/user/updateContact',
    method: 'post',
    data,
  })
}

// 获取用户资产
export const getUserAsset = (params) => {
  return http({
    url: 'api/marketing/user/assets',
    method: 'get',
    params,
  })
}

// 用户资产订单列表
export const getUserAssetList = (params) => {
  return http({
    url: 'api/marketing/user/assets/order',
    method: 'get',
    params,
  })
}

// 获取收款账户列表
export const getUserAccount = () => {
  return http({
    url: 'api/marketing/user/assets/account',
    method: 'get',
  })
}

// 添加收款账户列表
export const addUserAccount = (data) => {
  return http({
    url: 'api/marketing/user/assets/account',
    method: 'post',
    data,
  })
}
// 删除收款账户列表
export const deleteUserAccount = (data) => {
  return http({
    url: 'api/marketing/user/assets/account',
    method: 'delete',
    data,
  })
}

// 用户提现
export const userWithdrawal = (data) => {
  return http({
    url: 'api/marketing/user/assets/withdraw',
    method: 'post',
    data,
  })
}

// 用户申请角色
export const applyRole = (data) => {
  return http({
    url: 'api/marketing/user/applyRole',
    method: 'post',
    data,
  })
}
